package demo05;

import java.lang.reflect.Field;

/**
 * @author JYH
 * @version 1.0
 * @date 2022/10/27 10:13
 */
public class Test {
    public static void main(String[] args) throws Exception{
        //1.
        Class<Mouse> mouseClass = Mouse.class;
        Field price = mouseClass.getDeclaredField("price");
        System.out.println(price);
        //2.
        Field[] declaredFields = mouseClass.getDeclaredFields();
        for (Field field:declaredFields){
            System.out.println(field);
        }
        //3.
        Field age = mouseClass.getField("age");
        System.out.println(age);
        //4.
        Field[] fields = mouseClass.getFields();
        for (Field field:fields){
            System.out.println(field);
        }
    }
}
class Computer{
    public int age;
    private String kind;
}

class Mouse extends Computer{
    private double price;
    public int size;

    public void use(){
        System.out.println("这是use方法");
    }
}
